import request from '@/utils/request'

// 查询销售订单列表
export function listSales(query) {
  return request({
    url: '/xiaoshou/sale/list',
    method: 'get',
    params: query
  })
}

// 查询销售订单详细
export function getSales(id) {
  return request({
    url: '/xiaoshou/sale/' + id,
    method: 'get'
  })
}

// 新增销售订单
export function addSales(data) {
  return request({
    url: '/xiaoshou/sale',
    method: 'post',
    data: data
  })
}

// 修改销售订单
export function updateSales(data) {
  return request({
    url: '/xiaoshou/sale',
    method: 'put',
    data: data
  })
}

// 删除销售订单
export function delSales(id) {
  return request({
    url: '/xiaoshou/sale/' + id,
    method: 'delete'
  })
}


// 获取仓库列表
export function getWarehouseDeptList() {
  return request({
    url: '/xiaoshou/sale/warehouseDeptList',
    method: 'get'
  });
}
// 审核订单
export function auditSales(id, params) {
  return request({
    url: '/xiaoshou/sale/audit/' + id,
    method: 'put',
    params: params  // 确保这里传递了 action 参数
  });
}

// 出库订单
export function outboundSales(id) {
  return request({
    url: '/xiaoshou/sale/outbound/' + id,
    method: 'put'
  });
}

// 设为已支付
export function paySales(id) {
  return request({
    url: '/xiaoshou/sale/pay/' + id,
    method: 'put'
  });
}
export function listGoods(query) {
  return request({
    url: '/xiaoshou/sale/goodsList',
    method: 'get',
    params: query
  })
}

export function getOrderGoods(orderId) {
  return request({
    url: '/xiaoshou/sale/goods/' + orderId,
    method: 'get'
  })
}
